//
//  FirstTableViewCell.m
//  Final Ali
//
//  Created by dllo on 16/8/17.
//  Copyright © 2016年 yh. All rights reserved.
//

#import "FirstTableViewCell.h"
#import "MyCollectionViewCell.h"

@interface FirstTableViewCell () <UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout>
@property (strong, nonatomic) IBOutlet UICollectionView *collectionView;



@end


@implementation FirstTableViewCell
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    if (self.dataArray.count == 3) {
        return CGSizeMake((collectionView.bounds.size.width - 20) / 3, collectionView.bounds.size.height);
    } else {
    return CGSizeMake((collectionView.bounds.size.width - 20) / 3, (collectionView.bounds.size.height - 10) / 2);
    }
}
- (void)setDataArray:(NSArray *)dataArray {
    _dataArray = dataArray;
    [_collectionView reloadData];
}


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.dataArray.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    MyCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"collectReuse" forIndexPath:indexPath];
    return cell;
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
